﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

 
#region 导出
/// <summary>
/// 导出
/// </summary>
/// <typeparam name="T"></typeparam>
public class FilterExportInput<T> : PageInput<T>
{
    /// <summary>
    /// 文件名 
    /// </summary>
    public string FileName { get; set; } = "";

    /// <summary>
    /// 文件类型
    /// </summary>
    public string FileType { get; set; } = "";

    /*   private int limit = 1000;
       /// <summary>
       /// 数据条数
       /// </summary>
       public int Limit
       {
           get
           {
               if (this.limit < 1)
               {
                   return 1;
               }
               return this.limit;
           }
           set
           {
               this.CurrentPage = 1;
               this.PageSize = value;
               this.limit = value;
           }
       }*/

    private int min = -1;

    /// <summary>
    /// 起始数
    /// </summary>
    public int Min
    {
        get
        {
            if (min != -1)
            {
                this.Skip = min - 1;
                this.PageSize = this.Max - min + 1;
                this.Count = false;
            }
            return min;
        }
        set
        {
            this.min = value;
        }
    }
    /// <summary>
    /// 截止数
    /// </summary>
    public int Max { get; set; }




    /*
            /// <summary>
            /// 导出页数
            /// </summary>
            public List<int>? Pages { get; set; } = new List<int>() { 1 };
    */
    /// <summary>
    /// 是否显示标题
    /// </summary>
    public bool? ShowTitle { get; set; }

    /// <summary>
    /// 是否显示序号
    /// </summary>
    public bool? ShowSeq { get; set; }

    /// <summary>
    /// 标题
    /// </summary>
    public string? Title { get; set; }


    /// <summary>
    /// 导出列
    /// </summary>
    public List<Column>? Columns { get; set; }

}

/// <summary>
/// 导出
/// </summary>
public class ExcelExporterAttribute : Attribute
{
    /// <summary>
    /// 标题名称
    /// </summary>
    public string Title { get; set; } = "";

    /// <summary>
    /// 自动宽
    /// </summary>
    public bool AutoFitAllColumn { get; set; } = false;

    /// <summary>
    /// 默认宽
    /// </summary>
    public int Width { get; set; } = 80;

    /// <summary>
    /// 高
    /// </summary>
    public int Height { get; set; } = 30;

    /// <summary>
    /// 格式
    /// </summary>
    public string Format { get; set; } = "";

    /// <summary>
    /// 显示顺序
    /// </summary>
    public int OrderIndex { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public ExcelExporterAttribute()
    {
    }

    /// <summary>
    /// 是否导出图片
    /// </summary>
    public bool IsImg { get; set; }

    /// <summary>
    /// 是否base64图片
    /// </summary>
    public bool Base64Img { get; set; }

    /// <summary>
    /// 多图，Url逗号分隔，是否导出图片
    /// </summary>
    public bool IsMulImg { get; set; }
    /// <summary>
    /// JSON枚举值
    /// </summary>
    public string ValueMethod { get; set; } = "";
    /// <summary>
    /// 必须为 Public 
    /// </summary>
    public string ValueProperty { get; set; } = "";



}

#endregion

/// <summary>
/// 导出列信息
/// </summary>
public class Column
{
    /// <summary>
    /// 属性名
    /// </summary>
    public string Prop { get; set; } = "";
    /// <summary>
    /// 列名
    /// </summary>
    public string Label { get; set; } = "";


    /// <summary>
    /// 宽
    /// </summary>
    public object Width { get; set; } = "100";


    /// <summary>
    /// 对齐 left / center / right
    /// </summary>
    public string Align { get; set; } = "";

    /// <summary>
    /// left / center / right
    /// </summary>
    public string HeaderAlign { get; set; } = "";


    /// <summary>
    /// 子列，多级表头
    /// </summary>
    public List<Column>? Columns { get; set; }

}
